package com.sc.nft.dao;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.MallActivityRankingCycles;
import com.sc.nft.mapper.MallActivityRankingCyclesMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;


/**
 * IP商城活动兑换配置表(sc_mall_activity_exchange)数据DAO
 *
 * @author zxy
 * @description IP商城
 * @since 2023-05-10 16:59:01
 */
@Slf4j
@Repository
public class MallActivityRankingCyclesDao extends ServiceImpl<MallActivityRankingCyclesMapper, MallActivityRankingCycles> {

    public List<MallActivityRankingCycles> queryMallActivityRankingCyclesList(Long rankingId,Date payTime) {
        LambdaQueryWrapper<MallActivityRankingCycles> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(MallActivityRankingCycles::getIsDelete, 0)
                .eq(MallActivityRankingCycles::getRankingId, rankingId)
                .le(MallActivityRankingCycles::getStartTime, payTime)
                .ge(MallActivityRankingCycles::getEndTime, payTime);
        return list(queryWrapper);
    }

    public List<MallActivityRankingCycles> queryRankingCyclesByRankingId(Long rankingId) {
        LambdaQueryWrapper<MallActivityRankingCycles> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(MallActivityRankingCycles::getIsDelete, 0)
                .eq(MallActivityRankingCycles::getRankingId, rankingId)
                .gt(MallActivityRankingCycles::getStartTime, LocalDateTime.now());
        return list(queryWrapper);
    }
}